class Admin::SettlesController < AdminController
  def index
    @settles = Settle.all.order("created_at DESC").page(params[:page]).per(params[:per])
  end
  
  def edit
    @settle = Settle.find params[:id]
  end

  def update
    @settle = Settle.find params[:id]
    @settle.admin_id = current_admin.id
    if @settle.update settle_params
      redirect_to admin_settles_path, notice: "更新成功！"
    else
      redirect_to admin_settles_path, notice: "更新失败！"
    end
  end

  private

  def settle_params
    params.require(:settle).permit(:remark, :state)
  end
end
